import requests


class IHRMManageEmpApi:

    # 添加
    @classmethod
    def add_emp_api(cls, token, body):
        url = "http://ihrm2-test.itheima.net/api/sys/user"
        headr = {"Content-Type": "application/json", "Authorization": token}
        resp = requests.post(url=url, headers=headr, json=body)
        return resp

    # 查询
    @classmethod
    def query_emp_api(cls, emp_id, token):
        url = "http://ihrm2-test.itheima.net/api/sys/user/"+emp_id
        headr = {"Authorization": token}
        resp = requests.get(url=url, headers=headr)
        return resp

    # 修改
    @classmethod
    def modify_emp_api(cls, emp_id, token, body):
        url = "http://ihrm2-test.itheima.net/api/sys/user/"+emp_id
        headr = {"Content-Type": "application/json", "Authorization": token}
        resp = requests.put(url=url, headers=headr, json=body)
        return resp

    # 删除
    @classmethod
    def del_emp_id(cls, emp_id, token):
        url = "http://ihrm2-test.itheima.net/api/sys/user/"+emp_id
        headr = {"Authorization": token}
        resp = requests.delete(url=url, headers=headr)
        return resp
